#pragma once
#include "BasicSkinView.h"
#include "BasicSkinComboList.h"

namespace  BasicSkinView
{
	enum ECOMBO_STYLE
	{
		ECOMBO_SIMPLE = 1,		//CBS_SIMPLE
		ECOMBO_DROPDOWN = 2,	//CBS_DROPDOWN
		ECOMBO_DROPLIST = 3,	//CBS_DROPDOWNLIST
	};
	/*
	 *	desc:combo box
	 *	author:xxm
	 */
	class CBasicSkinCombo: public CBasicSkinView
	{
	public:
		CBasicSkinCombo(ECOMBO_STYLE eType);
		virtual ~CBasicSkinCombo();
	public:
		static CBasicSkinCombo* CreateBasicSkinCombo(ECOMBO_STYLE eType,CBasicSkinView* pParent,int x,int y,int cx,int cy,int cyDrop);
	public:
		void InitAsFontSizeCombo();
		void InitAsFontFaceCombo();
	public:
		virtual void BsSetObjectAttr(const wchar_t* szKey,void* lpData);
		virtual bool ProcessEvent(CBasicSkinEvent* pEvent);
		virtual void BsOnRenderView(CBasicSkinCanvas* pCanvas);
		virtual bool BsOnProcessWindowsMessage(CBasicSkinEvent* pEvent);
		virtual EBASICSKIN_CTRL_TYPE BsGetViewType();
		virtual void CB_ShowListBox(bool bTrack);
	public:
		void InitComboBox(CBasicSkinComboList* pList,int cyDropMax);
		void CB_ConnectSelectChangedEvent(void* pObj,...);
	public:
		void SetComboBkColor(Color& sClr,Color& eClr);
	public:
		int CB_AddString(const wchar_t* szAdd);
		bool CB_DeleteString(int nIndex);
		bool CB_SetTopIndex(int nIndex);
		int CB_GetTopIndex();
		void CB_GetButtonRect(LPRECT lpRect);
		void CB_EndAddList();
		void CB_ResetCombo();
	public:
		bool CB_MsgOkInInit(CBasicSkinEvent* pEvent);
		void CB_SetComboList(CBasicSkinComboList* pList);
		void CB_PressButton(bool bPress);
		void CB_HotTrack();
		bool CB_HideListBox(bool bNotifyEvent,bool bSelEndOk);
		void CB_InterSetCurSel(int nSel);
		void CB_SetCurSel(int nSel);
		int  CB_GetCurSel();
		void CB_SetItemHeight(int nHeight);
		void CB_SetTextFormat(UINT uFormat);
		int CB_FindItem(const wchar_t* szFind);
		bool CB_SetCurSel(const wchar_t* sz,bool bNotifySelect=false);
		wstring CB_GetText();
		void CB_SetFontSize(int nFontSize);
		int CB_GetFontSize();
		void CB_SetLineHeight(int nLineHeight);
	private:
		//Message Process
		bool CB_OnSysKeyDown(CBasicSkinEvent* pEvent);
		bool CB_OnKeyDown(CBasicSkinEvent* pEvent);
		bool CB_OnChar(CBasicSkinEvent* pEvent);
		void CB_UpdateListBox(bool bUpdate);
		void CB_CompleteEdit();
		void CB_KillFocus();
	public:
		CBasicSkinComboList*	m_pComboList;
		CBasicSkinView*			m_pComboEdit;
		bool					m_bLBoxVisible;
		bool					m_bNoEdit;
		bool					m_bButtonHotTracked;
		bool					m_bButtonPressed;
		bool					m_bMouseDown;
		int						m_nFormat;
		int						m_cyDrop;
		int						m_nFontSize;
		DWORD					m_dwBoxStyle;
		RECT					m_rcButton;
		Image*					m_pDownArrow;
		Image*					m_pUpArrow;
		Color					m_bkStartClr;
		Color					m_bkEndClr;
	};
}


/*
	//demo:
	CBasicSkinCombo* pCombo = CBasicSkinCombo::CreateBasicSkinCombo(ECOMBO_DROPDOWN,pRootView,rc.right-100,rc.top+230,80,25,50);
	for (int i = 0; i < 5; i++) 
	{
		pCombo->CB_AddString(L"Item1");
	}
	pCombo->SetComboBkColor(Color(254,255,255,255),Color(254,250,250,250));
	//pCombo->CB_ConnectSelectChangedEvent(this, &CBasicDialog::OnCombSelectChange);
*/